package com.chen.controller;

import com.chen.common.Result;
import com.chen.pojo.User;
import com.chen.service.Impl.LoginServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;


@RestController
@SuppressWarnings("all")
@RequestMapping("/user")
@Api(value = "LoginController", tags = "账户操作")
public class LoginController {
    private static Logger log = LoggerFactory.getLogger(LoginController.class);
    @Resource //自动装配
    private HttpServletRequest request;

    @Resource
    LoginServiceImpl loginService;

    //登录
    @PostMapping("/login")
    @ApiOperation("登录")
    public Result<?> login(@RequestBody User user) {
        return loginService.login(user);
    }


    @GetMapping("/info")
    @ResponseBody
    public Result info(@RequestParam String token) {

        log.info("调用了info接口=>");
        // token 这个用户登录时候获取的token  登录的时间
       return loginService.info(token);
    }
}
